'use strict';

const RouterService = require('../base');

class TravelService extends RouterService {
  static get modelName() {
    return 'Business.Travel';
  }
  getPageInclude() {
    return [
        {
            model: this.ctx.model.Business.TravelCategory,
            as: 'category'
        },
        {
          // skus
          model: this.ctx.model.Business.TravelSku,
          as: 'skus',
          attributes: ['id', 'name', 'share_price', 'stock', 'spec_combination']
        },
        {
          model: this.ctx.model.Business.TravelSpec,
          as: 'specs',
          attributes: ['id', 'spec_name', 'spec_values']
        },
        {
          model: this.ctx.model.System.SystemUser,
          as: 'creatorUser'
        }
    ]
  }
  getListInclude() {
    return this.getPageInclude()
  }

  setAfterPageQuery() {
    if (this.ctx.user) {
      if (this.ctx.user.role !== 1) {
        return {
          creator: this.ctx.user.id
        }
      }
    }
    return {
    }
  }
}

module.exports = TravelService;
